package com.fis.mca;

import java.util.Collection;

import com.fis.hlo.demo.dept.Dept;
import com.fis.hlo.demo.dept.DeptTransferer;
import com.fis.vaadin.utils.BaseTableForm;
import com.vaadin.ui.Table;
import client.DeptTransfererClient;

public class FormDept extends BaseTableForm<FormDeptDialog, Integer, Dept> {

	private static final long serialVersionUID = 1L;
	DeptTransferer service;
	
	public FormDept() {
		super();
		try {
			service=DeptTransfererClient.getService();
		} catch (Exception e) {
			e.printStackTrace();
		}
		loadDataForTable();
		
		
	}

	@Override
	public Collection<Dept> loadData() throws Exception {
		return service.getAll();
	}

	@Override
	public Integer insert(Dept value) throws Exception {
		return service.add(value);
	}

	@Override
	public void update(Dept value) throws Exception {
		service.update(value);
	}

	@Override
	public void delete(Dept value) throws Exception {
		service.delete(value);
	}

	@Override
	public String getTableName() throws Exception {
		return "SCOTT.DEPT";
	}

	@Override
	public String getConditionUnique(Dept value) throws Exception {
		return "DEPTNO='"+value.getDeptNo()+"'";
	}

	@Override
	public String getCaptionNameI18N() throws Exception {
		return "Dept info";
	}


	@Override
	public FormDeptDialog getLayoutDialog() throws Exception {
		return new FormDeptDialog();
	}

	@Override
	public Dept getDefaultValue() throws Exception {
		return new Dept();
	}

	@Override
	public Dept setPKValue(Dept newValue, Integer pk) throws Exception {
		newValue.setDeptNo(pk);
		return newValue;
	}

	@Override
	public void initTableColumn(Table tbl) {
		
	}

	@Override
	public String[] getFilterColumns() {
		return null;
	}

}
